

/**
  ******************************************************************************
  * @file    usb_desc.c
  * @author  Micha³ Budzoñ
  * @version V0.0.1
  * @date    17-August-2013
  ******************************************************************************/
#include "usb_regs.h"
#define VID										0x3333						
#define PID										0x1244

#define DEVICE_DESC_SIZE		                18
#define CONFIG_DESC_SIZE         				    9
#define CONFIG_DESC_TOTAL_SIZE         			18
#define INTERFACE_DESC_SIZE						      9
#define STRING_LANGID_SIZE					        4
#define STRING_VENDOR_SIZE            			14
#define STRING_PRODUCT_SIZE            			28
#define STRING_SERIAL_SIZE             			18
#define DEVICE_STATUS_SIZE						      2
#define STANDARD_ENDPOINT_DESC_SIZE         9
/*
* 说明：
* 决定上位机加载驱动类型取决于 (类代码，子类代码，协议)这个三元组在描述符两个地方出现
* 1.设备描述符,2.接口描述符,3.两者都可以
*
*| **Base Class** | **Descriptor Usage** | **Description**                                              |
*| -------------- | -------------------- | ------------------------------------------------------------ |
*| 00h            | Device               | [Use class information in the Interface Descriptors](https://www.usb.org/defined-class-codes#anchor_BaseClass00h) |
*| 01h            | Interface            | [Audio ](https://www.usb.org/defined-class-codes#anchor_BaseClass01h) |
*| 02h            | Both                 | [Communications and CDC Control](https://www.usb.org/defined-class-codes#anchor_BaseClass02h) |
*| 03h            | Interface            | [HID (Human Interface Device)](https://www.usb.org/defined-class-codes#anchor_BaseClass03h) |
*| 05h            | Interface            | [Physical](https://www.usb.org/defined-class-codes#anchor_BaseClass05h) |
*| 06h            | Interface            | [Image](https://www.usb.org/defined-class-codes#anchor_BaseClass06h) |
*| 07h            | Interface            | [Printer](https://www.usb.org/defined-class-codes#anchor_BaseClass07h) |
*| 08h            | Interface            | [Mass Storage](https://www.usb.org/defined-class-codes#anchor_BaseClass08h) |
*| 09h            | Device               | [Hub](https://www.usb.org/defined-class-codes#anchor_BaseClass09h) |
*| 0Ah            | Interface            | [CDC-Data](https://www.usb.org/defined-class-codes#anchor_BaseClass0Ah) |
*| 0Bh            | Interface            | [Smart Card](https://www.usb.org/defined-class-codes#anchor_BaseClass0Bh) |
*| 0Dh            | Interface            | [Content Security](https://www.usb.org/defined-class-codes#anchor_BaseClass0Dh) |
*| 0Eh            | Interface            | [Video](https://www.usb.org/defined-class-codes#anchor_BaseClass0Eh) |
*| 0Fh            | Interface            | [Personal Healthcare](https://www.usb.org/defined-class-codes#anchor_BaseClass0Fh) |
*| 10h            | Interface            | [Audio/Video Devices](https://www.usb.org/defined-class-codes#anchor_BaseClass10h) |
*| 11h            | Device               | [Billboard Device Class](https://www.usb.org/defined-class-codes#anchor_BaseClass11h) |
*| 12h            | Interface            | [USB Type-C Bridge Class](https://www.usb.org/defined-class-codes#anchor_BaseClass12h) |
*| 3Ch            | Interface            | [I3C Device Class ](https://www.usb.org/defined-class-codes#anchor_BaseClass3Ch) |
*| DCh            | Both                 | [Diagnostic Device](https://www.usb.org/defined-class-codes#anchor_BaseClassDCh) |
*| E0h            | Interface            | [Wireless Controller](https://www.usb.org/defined-class-codes#anchor_BaseClassE0h) |
*| EFh            | Both                 | [Miscellaneous](https://www.usb.org/defined-class-codes#anchor_BaseClassEFh) |
*| FEh            | Interface            | [Application Specific](https://www.usb.org/defined-class-codes#anchor_BaseClassFEh) |
*| FFh            | Both                 | [Vendor Specific](https://www.usb.org/defined-class-codes#anchor_BaseClassFFh) |
*
*
*
*
*/

/* USB标准设备描述符 */
const uint8_t DeviceDescriptor[DEVICE_DESC_SIZE] =
{
    DEVICE_DESC_SIZE,           /*该描述符长度 18字节 */
    DEVICE_DESCRIPTOR,			    /*该描述符类型 0x01*/
    0x00, 0x02,                 /*该设备使用USB协议版本 2.0*/
    0x02, 0x01,0x03,            /*类代码,子类代码,使用的协议,三元组决定加载的设备驱动*/
    0x40,                       /*端点0最大包长 64字节*/
    VID&0xFF, VID>>8,           /*厂商ID */ 
    PID&0xFF, PID>>8,           /*产品ID */
    0x00, 0x02,                 /*设备版本号 2.00*/
    1,                          /*描述厂商字符串索引ID */
    2,                          /*描述产品字符串索引ID*/
    3,                          /*产品序列号字符串索引ID */
    0x01                        /*配置个数*/
}; 


/* USB 配置描述符 */
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
const uint8_t ConfigDescriptor[CONFIG_DESC_TOTAL_SIZE] =
  {
    CONFIG_DESC_SIZE, 	        /* 配置描述符长度 9字节 */
    CONFIG_DESCRIPTOR,          /* 描述符类型 0x02 */
    CONFIG_DESC_TOTAL_SIZE, 0x00,/* 配置描述符总长度 */
    0x01,      		  					  /* 该配置支持的接口数 */
    0x01,      							    /* 该配置的值 */
    0x00,      							    /* 该配置的字符串索引*/
    0xC0,      							    /* 该配置的属性 自供电*/
    0x32,      							    /* 设备所需要的电流 2mA为单位 */
   /************** 接口描述符 ****************/
   /* 09 */
    INTERFACE_DESC_SIZE,        /* 该描述符长度 */
    INTERFACE_DESCRIPTOR,  	    /* 该描述符类型 0x04 */
    0x00,       						    /* 该接口编号，从0开始 */
    0x00,       						    /* 该接口的备用编号 */
    0x00,       						    /* 该接口使用端点个数，不包括端点0*/
    0x00, 0x00,  0x00,     			/*类代码,子类代码,使用的协议,三元组决定加载的设备驱动*/
    0,          						    /* 该接口所使用字符串索引值 */
   /******************** 端点描述符 ******************/
   /*端点描述符 
   *地址：大小为1字节 bit7：1输入，input，0输出，output;bit6-4:保留为0,bit3-0：端点号
   *属性：大小为1字节 bit1-0：表示端点传输类型，0控制传输，1同步传输，2批量传输，3中断传输
   *          如果端点不是同步传输则bit7-2为保留值。如果端点为同步传输：
   *          bit7-6:保留;
   *          bit5-4:表示用途，0数据端点，1反馈端点，2暗含反馈数据端点，3保留
   *          bit3-2:同步类型，0无同步，1异步，2适配，3同步
   */
                                /*  该描述符的长度 7字节*/
                                /*  该描述符类型， 0x05*/
                                /*  该端点的地址*/
                                /*  该端点的属性*/
                                /*  该端点支持的最大包长*/
                                /*  端点的查询时间*/


   /******************** Descriptor of additional interface ********************/
  }; /* Composite_ConfigDescriptor */

/* USB String Descriptors (optional) */
const uint8_t StringLangID[STRING_LANGID_SIZE] =
{
    STRING_LANGID_SIZE,
    STRING_DESCRIPTOR,
    0x09,
    0x04
}; /* LangID = 0x0409: U.S. English */

const uint8_t StringVendor[STRING_VENDOR_SIZE] =
  {
    STRING_VENDOR_SIZE, 		 /* Size of Vendor string */
    STRING_DESCRIPTOR,  		 /* bDescriptorType*/
    /* Manufacturer: "STMicroelectronics" */
    'B', 0,
	'u', 0,
	'd', 0,
	'z', 0,
	'i', 0,
	'k', 0
  };

const uint8_t StringProduct[STRING_PRODUCT_SIZE] =
  {
    STRING_PRODUCT_SIZE,       /* bLength */
    STRING_DESCRIPTOR,         /* bDescriptorType */
    'B', 0,
	'u', 0,
	'd', 0,
	'z', 0, 
	'i', 0,
	'k', 0,
	' ', 0,
	'D', 0,
	'e', 0,
	'v', 0,
    'i', 0,
	'c', 0,
	'e', 0
  };
  
const uint8_t StringSerial[STRING_SERIAL_SIZE] =
  {
    STRING_SERIAL_SIZE,           	/* bLength */
    STRING_DESCRIPTOR,     		    /* bDescriptorType */
    'B', 0,
	'D', 0,
	'Z', 0,
	' ', 0,
	'v', 0,
	'0', 0,
	'.', 0,
	'1', 0
  };
  
const uint8_t DeviceStatus[DEVICE_STATUS_SIZE] =
  {
    0x00,
	0x01
  };


